package elcs.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import elcs.board.model.BoardService;
import elcs.board.model.BoardVO;
import elcs.group.model.GroupService;
import elcs.member.model.MemberService;

@Controller
public class MainViewContoller {

	@Resource(name="boardServiceImpl")
	private BoardService boardService;
	
	@Resource(name="memberServiceImpl")
	private MemberService memberService;
	
	@Resource(name="groupServiceImpl")
	private GroupService groupService;
	
	
	@RequestMapping("/main.do")
	public ModelAndView mainView()
	{
		System.out.println("mainView");
		
		return new ModelAndView("home");
	}
	@RequestMapping("/loginview.do")
	public String loginView()
	{
		System.out.println("mainView");
		
		return "/WEB-INF/view/member/member_login";
	}
	@RequestMapping("/joinview.do")
	public String joinView()
	{
		System.out.println("joinView");
		
		return "register.member";
	}
	@RequestMapping("/sessionOut.do")
	public String sessionOut()
	{
		System.out.println("sessionOut");
		return "sessionout.member";
	}
	
	@RequestMapping("/aboutUs.do")
	public String aboutusView(){
		System.out.println("aboutusView");
		
		return "aboutus.aboutus";
	}
	
	@RequestMapping("/recentList.do")
	 @ResponseBody
	 public List<BoardVO> recentListAjax(BoardVO bvo) throws Exception{
	  System.out.println("recentList");
		 ModelAndView mv=new ModelAndView();
	  
	  List<BoardVO> list=boardService.recentList(bvo);
	 
	  System.out.println(list);
	  return list;
	 }
	
	@RequestMapping("/ranklist.do")
	 @ResponseBody
	 public List<BoardVO> ranklistAjax(String method) throws Exception{
	  System.out.println("ranklistAjax");
	  ModelAndView mv=new ModelAndView();
	  List list;
	  if(method.equalsIgnoreCase("member"))
	  {
		  list=memberService.findRankList();
	  }
	  else
	  {
		  list=groupService.findRankList();
	  }
	  System.out.println(list);
	  return list;
	 }
	
	
	
	
	

	
}
